/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ronin.model;

import com.ronin.common.model.MahalleKoy;
import com.ronin.common.model.Ilce;
import com.ronin.common.model.Il;
import com.ronin.common.model.Semt;
import com.ronin.model.constant.DurumEnum;
import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Version;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author esimsek
 */
@Entity
@Table(name = "firma")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Firma.findAll", query = "SELECT f FROM Firma f"),
    @NamedQuery(name = "Firma.findById", query = "SELECT f FROM Firma f WHERE f.id = :id"),
    @NamedQuery(name = "Firma.findByAd", query = "SELECT f FROM Firma f WHERE f.ad = :ad"),
    @NamedQuery(name = "Firma.findByAdres", query = "SELECT f FROM Firma f WHERE f.adres = :adres")})
public class Firma implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Long id;
    @Basic(optional = false)
    @Column(name = "ad")
    private String ad;
    @Column(name = "adres")
    private String adres;
    @JoinColumn(name = "semt_id", referencedColumnName = "id")
    @ManyToOne
    private Semt semt;
    @JoinColumn(name = "mah_id", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private MahalleKoy mahalle;
    @JoinColumn(name = "ilce_id", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Ilce ilce;
    @JoinColumn(name = "il_id", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Il il;
    @OneToMany(cascade = CascadeType.REFRESH, mappedBy = "firma")
    private List<Personel> personelList;
    @OneToMany(cascade = CascadeType.REFRESH, mappedBy = "firma")
    private List<Hizmet> hizmetList;
    @Enumerated(EnumType.ORDINAL)
    @Column(name = "durum_id")
    private DurumEnum durum;
    
    @Version
    private int versiyon;
    
    public Firma() {
    }

    public Firma(Long id) {
        this.id = id;
    }

    public Firma(Long id, String ad,DurumEnum durum) {
        this.id = id;
        this.ad = ad;
        this.durum = durum;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getAd() {
        return ad;
    }

    public void setAd(String ad) {
        this.ad = ad;
    }

    public String getAdres() {
        return adres;
    }

    public void setAdres(String adres) {
        this.adres = adres;
    }

    public Semt getSemt() {
        return semt;
    }

    public void setSemt(Semt semt) {
        this.semt = semt;
    }

    public MahalleKoy getMahalle() {
        return mahalle;
    }

    public void setMahalle(MahalleKoy mahalle) {
        this.mahalle = mahalle;
    }

    public Ilce getIlce() {
        return ilce;
    }

    public void setIlce(Ilce ilce) {
        this.ilce = ilce;
    }

    public Il getIl() {
        return il;
    }

    public void setIl(Il il) {
        this.il = il;
    }

    @XmlTransient
    public List<Personel> getPersonelList() {
        return personelList;
    }

    public void setPersonelList(List<Personel> personelList) {
        this.personelList = personelList;
    }

    @XmlTransient
    public List<Hizmet> getHizmetList() {
        return hizmetList;
    }

    public void setHizmetList(List<Hizmet> hizmetList) {
        this.hizmetList = hizmetList;
    }

    public int getVersiyon() {
        return versiyon;
    }

    public void setVersiyon(int versiyon) {
        this.versiyon = versiyon;
    }

    public DurumEnum getDurum() {
        return durum;
    }

    public void setDurum(DurumEnum durum) {
        this.durum = durum;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Firma)) {
            return false;
        }
        Firma other = (Firma) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.ronin.model.Firma[ id=" + id + " ]";
    }
    
}
